package cn.mldn.homework.networkProgramming.UDP;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class UDPServer
{
	public static void main(String[] args) throws Exception
	{
		DatagramSocket server = new DatagramSocket(8000); // 8000端口监听
		
		String str = "Hello, world"; // 发送消息
		
		DatagramPacket packet = new DatagramPacket(str.getBytes(), 0, str.length(), InetAddress.getByName("localhost"),
				8001); // 发送数据
		
		server.send(packet); // 发送消息
		System.out.println("消息发送完毕.....");
		server.close(); // 关闭服务端
	}
}
